package com.education.exception;

import com.education.result.ResultCodeEnum;
import lombok.Data;

/**
 * 统一的异常处理类
 * Created by Lance on 2020/06/23 21:17
 * 检查类异常 : 必须要 try catch 或者 throw
 * 运行时异常 : 是必检查的异常,可以不用做处理的
 */
@Data
public class OnlineEducationException extends RuntimeException{
    // 定义状态码
    private Integer code;

    /**
     * 接受状态码和消息
     * @param code  状态码
     * @param message   异常信息
     */
    public OnlineEducationException(Integer code, String message) {
        super(message);
        this.code=code;
    }

    /**
     * 接收枚举类型
     * @param resultCodeEnum
     */
    public OnlineEducationException(ResultCodeEnum resultCodeEnum) {
        super(resultCodeEnum.getMessage());
        this.code = resultCodeEnum.getCode();
    }
}
